Chris Pollett > Old Classes >
CS157b

( Print View )

Student Corner:
  [Grades Sec1]
  [Grades Sec2]

  [Submit Sec1]
  [Submit Sec2]

  [Email List Sec1]
  [Email List Sec2]

  [
Lecture Notes]

Course Info:
  [Texts & Links]
  [Topics]
  [Grading]
  [HW Info]
  [Exam Info]
  [Regrades]
  [Honesty]
  [Announcements]

HW Assignments:
  [Hw1]  [Hw2]  [Hw3]
  [Hw4]  [Hw5]

Practice Exams:
  [Mid1]  [Mid2]  [Final]

                           












HW#2 --- last modified March 02 2019 21:17:20..

Solution set.

Due date: Mar 9

Files to be submitted:
  Hw2Problems.pdf
  DataGenerator.java
  DataLoader.ctl
  SelectTest.java
  Experiments.txt

Purpose: To become more familiar with database record structures, indexes, and B-trees. To do some simple connection experiments with Oracle.

Specification:

Do the following problems out of the book: 3.3.10, 3.5.1, 4.1.1, 4.3.5, 4.4.1, and submit them in the file Hw2Problems.pdf. For people with the Complete book here are the (problems as a PDF). Be aware that some of the problems are starred which means their answers are on-line. You should try to do the problem yourself, before looking at any such answers and your write-up of what you submit should be entirely your own.

For the remainder of the assignment your goal is to do some simple benchmarking to observe how effective indexes are at speeding up the access of data in a database. For this purpose, I want you to create a table MyTable with two columns: A and B. A is an INTEGER and is the table's primary key and B is a CHAR(100) field. Write a short program DataGenerator.java which when run from the command line with a line like:

java DataGenerator tmp.DAT 1000

would output to the file tmp.DAT 1000 rows of data. Each row should consist of an integer, a tab, a random string of length 100 of characters between a to z, and a new line. The integers should increase by one as you loop through to output these rows and should start with 1. If I change the name of the file or the number of rows, the program should make use of these new parameters. Next create a file DataLoader.ctl to bulk load this data into MyTable within Oracle using sqlldr. Now write a program SelectTest.java which is run from the command line with a line like:

java SelectTest tmp.DAT 455

This searches the file tmp.DAT (or whatever the file specified in this command line argument) for line 455. The data can be assumed to be data created from the DataGenerator program. It reads the string in from the second field and then opens a JDBC connection to the cs157b database and does the query: SELECT * FROM MyTable WHERE B=whatever this string was. SelectTest times how long this query takes and outputs the whole row together with this time. To complete this homework, you should now do various experiments with this program. You should try generating more and less data and see how it affect the query time. Then you should create an index on B and repeat these experiments to see if the time to do the query changes. Write up your experimental results in Experiments.txt.

Point Breakdown

Departmental coding guidelines for Java followed 1pt
Book problems (1/2pt each) 2.5pt
DataGenerator.java works as described1pt
DataLoader.ctl can bulk load data output from DataGenerator .5pts
SelectTest.java works as described3pts
Write up in Experiments.txt2pts
Total10pts